/**
 * Created Date: Tuesday, October 24th 2023, 10:54:51 am
 * Author: CodingGorit
 * -----
 * Last Modified: Tue Oct 24 2023
 * Modified By: CodingGorit
 * -----
 * Copyright © 2019 —— 2023 fmin-courses TP Center All Rights Reserved
 * ------------------------------------
 * Javascript will save your soul!
 */


export const objToArr = <T>(obj: { [key: string]: T }) => {
    return Object.keys(obj).map(key => obj[key])
}

export const arrToObj = <T extends { _id?: string }>(arr: Array<T>) => {
    return arr.reduce((prev, current) => {
      if (current._id) {
        prev[current._id] = current
      }
      return prev
    }, {} as { [key: string]: T })
  }